package Week5;

import java.util.Scanner;

class IllegalScoreException extends Exception{
	public IllegalScoreException(){
	}
	public IllegalScoreException(String str){
		super(str);
	}
}

class IllegalNameException extends Exception{
	public IllegalNameException(){
	}
	public IllegalNameException(String str){
		super(str);
	}
}

class Studentsss{
	private String name;
	private int score;
	public Studentsss(String name,int score)throws Exception{
		setName(name);
		setScore(score);
		addScore(score);
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name)throws Exception {
			if(name.charAt(0)>='0'&&name.charAt(0)<='9') throw new IllegalNameException("the first char of name must not be digit, name="+name);
			this.name = name;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	@Override
	public String toString() {
		return "Student [name=" + name + ", score=" + score + "]";
	}
	public int addScore(int score) throws Exception{
		if(score<0||score>100) throw new IllegalScoreException("score out of range, score="+score);
		return score;
	}
}

public class Main5 {
	public static void main(String[] arge){
		Scanner in=new Scanner(System.in);
		String str;
		String name;
		int score;
		while(in.hasNextLine()){
			str=in.next();
			if(!str.equals("new"))
				break;
			try{
				name=in.next();
				score=in.nextInt();
				Studentsss student=new Studentsss(name,score);
				System.out.println(student);
			}catch(IllegalNameException e){
				System.out.println(e);
				break;
			}catch(IllegalScoreException e){
				System.out.println(e);
				continue;
			}
		}
		in.close();
		System.out.println("scanner closed");
	}
}
